Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gdbinit #4744

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update gdbinit #4744

wants to merge 1 commit into from

Conversation

jinger7281
Copy link

fix wrong path of libstdcxx python script
If the version number of gcc was updated, but this script was not update the variable of %GCC_NAME% which will lead an error of missing libstdcxx module
This update use python script to search the real path of the gcc folder and insert it into the sys.path variable

fix wrong path of libstdcxx python script
@lazka
Copy link
Member

lazka commented Jul 4, 2024

Sounds good. One thing I noticed is that have multiple dirs left because of python cache files (we should try fix this with the next gcc update).

$ echo /usr/share/gcc*
/usr/share/gcc-11.3.0 /usr/share/gcc-13.2.0 /usr/share/gcc-13.3.0

A hacky workaround is to sort the dirs, which is a good idea anyway since listdir order isn't stable.

What about:

import sys
import glob
python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True)
sys.path.insert(0, (python_dirs or [sys.path[0])[0])

@lazka
Copy link
Member

lazka commented Jul 4, 2024

Or we add a big warning to the gcc build file that gdb needs to be rebuilt on version changes.

@lazka
Copy link
Member

lazka commented Jul 4, 2024

I've created #4748 as an alternative

@jinger7281
Copy link
Author

jinger7281 commented Jul 5, 2024

@lazka

Sounds good. One thing I noticed is that have multiple dirs left because of python cache files (we should try fix this with the next gcc update).

$ echo /usr/share/gcc*
/usr/share/gcc-11.3.0 /usr/share/gcc-13.2.0 /usr/share/gcc-13.3.0

A hacky workaround is to sort the dirs, which is a good idea anyway since listdir order isn't stable.

What about:

import sys
import glob
python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True)
sys.path.insert(0, (python_dirs or [sys.path[0])[0])

This may be a good idea. Some newbies like me are always confused about the prompt, and don't know how to deal with this, we added this method to provide a way for newbies to easily use it.

> import sys
> import glob
> python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True)
> sys.path.insert(0, (python_dirs or sys.path)[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants